﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GamePanel : GUIPanel {


	[SerializeField]
	UILabel ScoreLabel;

	/*
	[SerializeField]
	UISprite OldScorePrefab;
	[SerializeField]
	UISprite NewScorePrefab;

	GameObject NewScoreObject;
	GameObject OldScoreObject;
	
	UISprite NewScore;
	UISprite OldScore;

	string exchangeOldScore;
	/*
	void Awake()
	{
		NewScoreObject = NGUITools.AddChild(this.transform.gameObject, NewScorePrefab.gameObject);
		NewScore = NewScoreObject.GetComponent<UISprite>();
		NewScoreObject.transform.localScale = new Vector3(0.5f,0.5f,0.5f);
		NewScore.spriteName = "";
		
		OldScoreObject = NGUITools.AddChild(this.transform.gameObject, OldScorePrefab.gameObject);
		OldScore = OldScoreObject.GetComponent<UISprite>();
		OldScore.spriteName = "Score0" ;
		OldScoreObject.transform.localPosition = new Vector3(0,360,0);
		OldScoreObject.transform.localScale = new Vector3(0.5f,0.5f,0.5f);

	}*/


	public override void OnOpen ()
	{
		base.OnOpen ();

		SetScore (0);
	}


	public void SetScore(int s)
	{

		ScoreLabel.text = s.ToString ();

		//int range = s.ToString().Length;

		//fadeIn(s);

		//fadeOut(OldScore);
	

	}

	/*
	void fadeIn(int s){
		TweenPosition.Begin(NewScoreObject, 1.0f,new Vector3(35,450,0) );
		NewScoreObject.GetComponent<TweenPosition>().from = new Vector3(35,450,0);
		NewScoreObject.GetComponent<TweenPosition>().to = new Vector3(0,360,0);
		NewScore.spriteName = "Score" + s;
		TweenAlpha.Begin(NewScoreObject,1.0f,0.0f);
		NewScoreObject.GetComponent<TweenAlpha>().from = 0.0f;
		NewScoreObject.GetComponent<TweenAlpha>().to = 1.0f;


	}

	void fadeOut(UISprite OldScore){

		OldScore.spriteName = exchangeOldScore;
		Debug.Log("OldScore.spriteName" + OldScore.spriteName);
		TweenPosition.Begin(OldScoreObject, 1.0f,new Vector3(0,360,0) );
		OldScoreObject.GetComponent<TweenPosition>().from = new Vector3(0,360,0);
		OldScoreObject.GetComponent<TweenPosition>().to = new Vector3(-35,300,0);

		TweenAlpha.Begin(OldScoreObject,1.0f,1.0f);
		OldScoreObject.GetComponent<TweenAlpha>().from = 1.0f;
		OldScoreObject.GetComponent<TweenAlpha>().to = 0;
		Debug.Log("NewScore.spriteName" + NewScore.spriteName);
		exchangeOldScore = NewScore.spriteName;

	}*/


}



